package awd.bj.jls.webs.api.hystrix;

import awd.bj.jls.webs.api.ManagerApi;
import awd.bj.jls.webs.api.model.User;
import awd.bj.jls.webs.api.model.WgTree;
import awd.bj.jls.webs.utils.PagerResult;
import awd.bj.jls.webs.utils.QueryParam;
import awd.bj.jls.webs.utils.ResponseMessage;
import awd.bj.manager.model.ClassficModel;
import awd.bj.manager.model.MenusModel;
import awd.bj.manager.model.WgzdModel;
import com.google.common.collect.Lists;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Description
 * @Author WS
 * @Date 2019-09-17 14:21
 */
@Component
public class ManagerApiFallBackFactory implements FallbackFactory<ManagerApi> {

    Logger logger = LoggerFactory.getLogger(ManagerApi.class);

    @Override
    public ManagerApi create(Throwable cause) {
        return new ManagerApi() {
            @Override
            public ResponseMessage<String> classficAdd(ClassficModel var1) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<List<ClassficModel>> classficList(Map<String, String[]> var1) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<Integer> classficUpdateByPrimaryKey(String var1, ClassficModel var2) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<List<ClassficModel>> classficFindNode(String var1) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<List<ClassficModel>> classficFindNodes(String var1) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<PagerResult<ClassficModel>> classficQuery(Map<String, String[]> var1) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<PagerResult<ClassficModel>> classficGetAllClassfic() {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<List<ClassficModel>> classficFindWgNode(String var1, String var2) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public List<WgTree> getWgTreeList(String id) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return Lists.newArrayList();
            }

            @Override
            public ResponseMessage<List<WgzdModel>> wgzdList(Map<String, String[]> map) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<PagerResult<WgzdModel>> wgzdQueryForPage(Map<String, String[]> map) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<WgzdModel> wgzdGetByid(String id) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<String> wgzdSave(WgzdModel wgzdModel) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<String> wgzdSaveorupdate(WgzdModel wgzdModel) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<String> wgzdUpdate(String id, WgzdModel wgzdModel) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<User> getUserByName(String jsbh, String username) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<String> menusSave(String appcode, String menu, String fname, String name, String url, String creator, Date createtime) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<PagerResult<MenusModel>> menusQuery(QueryParam param) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }

            @Override
            public ResponseMessage<String> settingInit(String aPPCODE, String progroup, String type, String key, String pronamezh, String value, String creator) {
                cause.printStackTrace();
                logger.info("进入熔断器=======>>" + Thread.currentThread().getStackTrace()[1].getMethodName() + "方法执行出错");
                return ResponseMessage.error("查询出错！");
            }
        };
    }
}
